<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let arr = new Array(1, 2, 3, 4);
        //将头部删除,返回的是被删除的元素
        // let res = arr.shift();
        // console.log(res,arr);

        Array.prototype.myShift = function(){

            //记录会被 干掉的元素 
            let first = this[0]

            for(let i = 1 ; i < this.length ; i++){
                this[i-1] = this[i]
            }
            this.length --

            return first;
        }
        let result = arr.myShift();
        console.log(result,arr);
    </script>
</body>
</html>